package com.example.object;

import java.net.MalformedURLException;
import java.net.URL;

public class Main2 {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://www.runoob.com/html/html-tutorial.html");
        System.out.println("URL是" + url.toString());
        System.out.println("协议是" + url.getProtocol());
        System.out.println("主机名是" + url.getHost());
        System.out.println("端口号是" + url.getPort());
        System.out.println("文件名是" + url.getFile());
        System.out.println("路径是" + url.getPath());
        System.out.println("查询字符串是" + url.getQuery());
        System.out.println("默认端口号是:" + url.getDefaultPort());
    }
}
